//
// Created on 2024/4/26.
//
// Node APIs are not fully supported. To solve the compilation error of the interface cannot be found,
// please include "napi/native_api.h".

#ifndef RONGIMLIBTESTDEMO_RCIMNAPICONTEXT_H
#define RONGIMLIBTESTDEMO_RCIMNAPICONTEXT_H
#include "models/NativeObject.h"
#include "napi/native_api.h"
#include "rcim_client_adapter.h"

#include <vector>

namespace rcim {
namespace context {

// Listener 相关 *******************************************************
/**
 * 通过 ArkTS Listener 生成 context。例如 ArkTS 层的连接状态监听接口
 * @param env
 * @param listener_value
 * @return context
 */
void *genContextByListener(const Engine *engine, napi_env env, napi_value listener_value);
/**
 * 从 Listener 的上下文中获取 engine
 * @param context Listener 的上下文
 * @return engine
 */
const Engine *getEngineFromContextByListener(const void *context);

const napi_threadsafe_function getThreadSafeFunctionFromContext(const void *context);
/**
 * 主动回调 ArkTS，用于将 rust Listener 回调给 ArkTS 层
 * @param context
 * @param vec
 */
void callArkTSListenerForAsyncMethod(const void *context, std::vector<NativeObject *> *vec);

} // namespace context
} // namespace rcim
#endif // RONGIMLIBTESTDEMO_RCIMNAPICONTEXT_H
